package com.zhentao.service.impl;

import com.zhentao.domain.Product;
import com.zhentao.service.AuditService;
import com.zhentao.service.ProductService;
import com.zhentao.until.TextModerationPlusDemo;
import lombok.SneakyThrows;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AuditServiceImpl implements AuditService {
    @Autowired
    private ProductService productService;
    @SneakyThrows
    @Override
    public String auditProduct(Product product) {
        String result = TextModerationPlusDemo.contentText(product.getDescription());
        if (result.equals("审核通过")){
            product.setAudit(1);
            productService.updateById(product);
            return "审核通过";
        }
        if (result.equals("审核失败")){
            product.setAudit(2);
            productService.updateById(product);
            return "审核失败";
        }
        if (result.equals("转人工")){
            product.setAudit(1);
            productService.updateById(product);
            return "转人工";
        }
        return "转人工";
    }
}
